tsteven fixes a horrible hack of mine in kml.c. Replace invalid low-order
authorrobertlipe@gmail.com <robertlipe@gmail.com@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Mon, 14 May 2012 14:35:49 +0000 (14:35 +0000)
committerrobertlipe@gmail.com <robertlipe@gmail.com@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Mon, 14 May 2012 14:35:49 +0000 (14:35 +0000)
characters in XML with whitespace in all XML files, including KML.  Revert
hack in kml.c  Fix LineStyles test files which come from TPO3.

git-svn-id: http://gpsbabel.googlecode.com/svn/trunk@4179 f51c46e8-681c-474f-0cfe-069cfd0219fb

gpsbabel/kml.c
gpsbabel/reference/LineStyles.gpx
gpsbabel/reference/LineStyles.kml
gpsbabel/util.c

index 4d9ee0dbbcbc34ff3bec86d916acb59685a1ffff..ccd023c0953120f4185b757959d464f9f3e4163b 100644 (file)
@@ -1473,18 +1473,7 @@ static void kml_waypt_pr(const waypoint* waypointp)
     xfree(odesc);
   } else {
     if (strcmp(waypointp->shortname, waypointp->description)) {
-      // This is a hack.  The entitizer code really should catch this,
-      // but this is the low risk fix for now - just toss bad chars.
-      int j;
-      char* t = xstrdup(waypointp->description);
-      for (j = 0; t[j] != 0; j++) {
-        if (t[j] < ' ') {
-          t[j] = ' ';
-        }
-      }
-
-      kml_write_xmle("description", t);
-      xfree(t);
+      kml_write_xmle("description", waypointp->description);
     }
   }
 
index 8168e13b48b962ce2203dca7e9bb1b7d84656942..acdf9b872a7a7944b0ca43e52a54e468d1419849 100644 (file)
@@ -81,8 +81,8 @@
 </wpt>
 <wpt lat="37.522060037" lon="-122.277670026">
   <name>NOTE 1</name>
-  <cmt>12 test lines - see notes with GPX sample!!\rfour line widths for solid red\rtwo line widths for dashed red\rseven colors for medium width\rNote that line names have nothing at all to do with line style attributes!\vThese are named for convenient cross-reference,\r   but keep in mind that &quot;red med&quot; is a line label and &quot;Red Medium&quot; is a style label.\rWaypoints are generated by Topo to exactly match the first track point.\rApparently only GPX and KML output from GPSBabel retain track descriptions??</cmt>
-  <desc>12 test lines - see notes with GPX sample!!\rfour line widths for solid red\rtwo line widths for dashed red\rseven colors for medium width\rNote that line names have nothing at all to do with line style attributes!\vThese are named for convenient cross-reference,\r   but keep in mind that &quot;red med&quot; is a line label and &quot;Red Medium&quot; is a style label.\rWaypoints are generated by Topo to exactly match the first track point.\rApparently only GPX and KML output from GPSBabel retain track descriptions??</desc>
+  <cmt>12 test lines - see notes with GPX sample!!\rfour line widths for solid red\rtwo line widths for dashed red\rseven colors for medium width\rNote that line names have nothing at all to do with line style attributes! These are named for convenient cross-reference,\r   but keep in mind that &quot;red med&quot; is a line label and &quot;Red Medium&quot; is a style label.\rWaypoints are generated by Topo to exactly match the first track point.\rApparently only GPX and KML output from GPSBabel retain track descriptions??</cmt>
+  <desc>12 test lines - see notes with GPX sample!!\rfour line widths for solid red\rtwo line widths for dashed red\rseven colors for medium width\rNote that line names have nothing at all to do with line style attributes! These are named for convenient cross-reference,\r   but keep in mind that &quot;red med&quot; is a line label and &quot;Red Medium&quot; is a style label.\rWaypoints are generated by Topo to exactly match the first track point.\rApparently only GPX and KML output from GPSBabel retain track descriptions??</desc>
 </wpt>
 <wpt lat="37.522349358" lon="-122.284910083">
   <name>NOTE 2</name>
index 86137c815c80ec3f24243a0d94a8a37201e3859a..6f3c7bc6a0545e20e43e333009618fff1e1046ea 100644 (file)
       </Placemark>
       <Placemark>
         <name>NOTE 1</name>
-        <description>12 test lines - see notes with GPX sample!! four line widths for solid red two line widths for dashed red seven colors for medium width Note that line names have nothing at all to do with line style attributes! These are named for convenient cross-reference,    but keep in mind that &quot;red med&quot; is a line label and &quot;Red Medium&quot; is a style label. Waypoints are generated by Topo to exactly match the first track point. Apparently only GPX and KML output from GPSBabel retain track descriptions??</description>
+        <description>12 test lines - see notes with GPX sample!!\rfour line widths for solid red\rtwo line widths for dashed red\rseven colors for medium width\rNote that line names have nothing at all to do with line style attributes! These are named for convenient cross-reference,\r   but keep in mind that &quot;red med&quot; is a line label and &quot;Red Medium&quot; is a style label.\rWaypoints are generated by Topo to exactly match the first track point.\rApparently only GPX and KML output from GPSBabel retain track descriptions??</description>
         <styleUrl>#waypoint</styleUrl>
         <Point>
           <coordinates>-122.277670,37.522060</coordinates>
       </Placemark>
       <Placemark>
         <name>NOTE 2</name>
-        <description>how GPX from GPSBabel shows Topo track desc as of 2012: (line name and line style are NOT related to actual color or width)  &lt;trk&gt;   &lt;name&gt;red line&lt;/name&gt;   &lt;desc&gt;Style=red med, Width=3, Dashed=0, Color=#ff0000&lt;/desc&gt; &lt;number&gt;1&lt;/number&gt; &lt;trkseg&gt; ... (Topo menu colors are stored in the file as web-style hex RGB)   Red=#ff0000, Yellow=#ffff00, Green=#008000, Blue=#000080,   Purple=#800080, Black=#000000, White=#ffffff (Topo solid  line widths: Hairline=1, Thin=2, Medium=3, Thick=4) (Topo dashed line widths: Hairline=1, Thin=2) SRE&apos;s tpo.c mod stuffs Style/Width/Dashed/Color fields into &quot;desc&quot; field   under the assumption that something will post-process GPX or KML output   and move information from desc to private extensions (solid  lines have &quot;Dashed=0&quot;, can have width of 1=hairline to 4=thick) (dashed lines have &quot;Dashed=1&quot;, can only have width of 1=hairline or 2=thin) </description>
+        <description>how GPX from GPSBabel shows Topo track desc as of 2012:\r(line name and line style are NOT related to actual color or width)\r\r&lt;trk&gt;\r  &lt;name&gt;red line&lt;/name&gt;\r  &lt;desc&gt;Style=red med, Width=3, Dashed=0, Color=#ff0000&lt;/desc&gt;\r&lt;number&gt;1&lt;/number&gt;\r&lt;trkseg&gt;\r...\r(Topo menu colors are stored in the file as web-style hex RGB)\r  Red=#ff0000, Yellow=#ffff00, Green=#008000, Blue=#000080,\r  Purple=#800080, Black=#000000, White=#ffffff\r(Topo solid  line widths: Hairline=1, Thin=2, Medium=3, Thick=4)\r(Topo dashed line widths: Hairline=1, Thin=2)\rSRE&apos;s tpo.c mod stuffs Style/Width/Dashed/Color fields into &quot;desc&quot; field\r  under the assumption that something will post-process GPX or KML output\r  and move information from desc to private extensions\r(solid  lines have &quot;Dashed=0&quot;, can have width of 1=hairline to 4=thick)\r(dashed lines have &quot;Dashed=1&quot;, can only have width of 1=hairline or 2=thin)\r</description>
         <styleUrl>#waypoint</styleUrl>
         <Point>
           <coordinates>-122.284910,37.522349</coordinates>
       </Placemark>
       <Placemark>
         <name>NOTE 3</name>
-        <description>how KML from GPSBabel shows Topo track desc as of 2012: (see important notes with GPX sample, all of them apply here!) (note that GPSBabel forces all track styles to be the same - why?)      &lt;Folder&gt;       &lt;name&gt;Tracks&lt;/name&gt;       &lt;Folder&gt;         &lt;name&gt;red line&lt;/name&gt;         &lt;snippet/&gt;         &lt;description&gt; &lt;![CDATA[&lt;table&gt;             &lt;tr&gt;&lt;td&gt;&lt;b&gt;Description&lt;/b&gt; Style=Red Medium, Width=3, Dashed=0, Color=#ff0000 &lt;/td&gt;&lt;/tr&gt;             &lt;tr&gt;&lt;td&gt;&lt;b&gt;Distance&lt;/b&gt; 1.3 mi &lt;/td&gt;&lt;/tr&gt;           &lt;/table&gt;]]&gt;         &lt;/description&gt;         &lt;Folder&gt;           &lt;name&gt;Points&lt;/name&gt;           &lt;Placemark&gt;             &lt;name&gt;red line-0&lt;/name&gt; ...</description>
+        <description>how KML from GPSBabel shows Topo track desc as of 2012:\r(see important notes with GPX sample, all of them apply here!)\r(note that GPSBabel forces all track styles to be the same - why?)\r\r    &lt;Folder&gt;\r      &lt;name&gt;Tracks&lt;/name&gt;\r      &lt;Folder&gt;\r        &lt;name&gt;red line&lt;/name&gt;\r        &lt;snippet/&gt;\r        &lt;description&gt;\r&lt;![CDATA[&lt;table&gt;\r            &lt;tr&gt;&lt;td&gt;&lt;b&gt;Description&lt;/b&gt; Style=Red Medium, Width=3, Dashed=0, Color=#ff0000 &lt;/td&gt;&lt;/tr&gt;\r            &lt;tr&gt;&lt;td&gt;&lt;b&gt;Distance&lt;/b&gt; 1.3 mi &lt;/td&gt;&lt;/tr&gt;\r          &lt;/table&gt;]]&gt;\r        &lt;/description&gt;\r        &lt;Folder&gt;\r          &lt;name&gt;Points&lt;/name&gt;\r          &lt;Placemark&gt;\r            &lt;name&gt;red line-0&lt;/name&gt;\r...</description>
         <styleUrl>#waypoint</styleUrl>
         <Point>
           <coordinates>-122.288962,37.522691</coordinates>
       </Placemark>
       <Placemark>
         <name>NOTE 4</name>
-        <description>how MapSource 6.16.3 adds color to a track as of 2012: (color choices are Dark Gray, Red, Green, Yellow, Blue, Magenta, Cyan, White, Transparent) (should be easy to turn desc tag into their extension, but better to directly write track styles)    &lt;trk&gt;     &lt;name&gt;Hwy 50 from Placerville&lt;/name&gt;     &lt;extensions&gt;       &lt;gpxx:TrackExtension xmlns:gpxx=&quot;http://www.garmin.com/xmlschemas/GpxExtensions/v3&quot;&gt;         &lt;gpxx:DisplayColor&gt;Red&lt;/gpxx:DisplayColor&gt;       &lt;/gpxx:TrackExtension&gt;     &lt;/extensions&gt;     &lt;trkseg&gt; ... </description>
+        <description>how MapSource 6.16.3 adds color to a track as of 2012:\r(color choices are Dark Gray, Red, Green, Yellow, Blue, Magenta, Cyan, White, Transparent)\r(should be easy to turn desc tag into their extension, but better to directly write track styles)\r\r  &lt;trk&gt;\r    &lt;name&gt;Hwy 50 from Placerville&lt;/name&gt;\r    &lt;extensions&gt;\r      &lt;gpxx:TrackExtension xmlns:gpxx=&quot;http://www.garmin.com/xmlschemas/GpxExtensions/v3&quot;&gt;\r        &lt;gpxx:DisplayColor&gt;Red&lt;/gpxx:DisplayColor&gt;\r      &lt;/gpxx:TrackExtension&gt;\r    &lt;/extensions&gt;\r    &lt;trkseg&gt;\r...\r</description>
         <styleUrl>#waypoint</styleUrl>
         <Point>
           <coordinates>-122.272938,37.522105</coordinates>
index 0be028193aef164a2d8181d70c517123b9084eff..65460b3ab1e908faf9430a413056f934fa65d533 100644 (file)
@@ -1699,6 +1699,37 @@ entity_types stdentities[] =  {
   { "<",       "&lt;", 0 },
   { ">",       "&gt;", 0 },
   { "\"",      "&quot;", 0 },
+  { "\x01",    " ", 1 }, // illegal xml 1.0 character
+  { "\x02",    " ", 1 }, // illegal xml 1.0 character
+  { "\x03",    " ", 1 }, // illegal xml 1.0 character
+  { "\x04",    " ", 1 }, // illegal xml 1.0 character
+  { "\x05",    " ", 1 }, // illegal xml 1.0 character
+  { "\x06",    " ", 1 }, // illegal xml 1.0 character
+  { "\x07",    " ", 1 }, // illegal xml 1.0 character
+  { "\x08",    " ", 1 }, // illegal xml 1.0 character
+  // { "\x09", " ", 1 },  legal xml 1.0 character
+  // { "\x0a", " ", 1 },  legal xml 1.0 character
+  { "\x0b",    " ", 1 }, // illegal xml 1.0 character
+  { "\x0c",    " ", 1 }, // illegal xml 1.0 character
+  // { "\x0d", " ", 1 },  legal xml 1.0 character
+  { "\x0e",    " ", 1 }, // illegal xml 1.0 character
+  { "\x0f",    " ", 1 }, // illegal xml 1.0 character
+  { "\x10",    " ", 1 }, // illegal xml 1.0 character
+  { "\x11",    " ", 1 }, // illegal xml 1.0 character
+  { "\x12",    " ", 1 }, // illegal xml 1.0 character
+  { "\x13",    " ", 1 }, // illegal xml 1.0 character
+  { "\x14",    " ", 1 }, // illegal xml 1.0 character
+  { "\x15",    " ", 1 }, // illegal xml 1.0 character
+  { "\x16",    " ", 1 }, // illegal xml 1.0 character
+  { "\x17",    " ", 1 }, // illegal xml 1.0 character
+  { "\x18",    " ", 1 }, // illegal xml 1.0 character
+  { "\x19",    " ", 1 }, // illegal xml 1.0 character
+  { "\x1a",    " ", 1 }, // illegal xml 1.0 character
+  { "\x1b",    " ", 1 }, // illegal xml 1.0 character
+  { "\x1c",    " ", 1 }, // illegal xml 1.0 character
+  { "\x1d",    " ", 1 }, //illegal xml 1.0 character
+  { "\x1e",    " ", 1 }, //illegal xml 1.0 character
+  { "\x1f",    " ", 1 }, //illegal xml 1.0 character
   { NULL,      NULL, 0 }
 };